﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Cfg;
using System.IO;
using NHibernate;
using HX.Common;

namespace HX.Data
{
    public class Helper
    {
        public static readonly Configuration Configuration;
		public static readonly ISessionFactory SessionFactory;

        static Helper()
		{
			log4net.Config.XmlConfigurator.Configure();
			Configuration = new Configuration();
			string nhConfigPath = Utils.GetMapPath("/nhibernate.cfg.xml");
			if (File.Exists(nhConfigPath))
			{
				Configuration.Configure(nhConfigPath);
			}
            Configuration.AddAssembly("HX.HBM");
			
			SessionFactory = Configuration.BuildSessionFactory();
		}
		
		public static ISession GetCurrentSession()
		{
			return SessionFactory.GetCurrentSession();
		}
    }

}
